const Router = require("express").Router()
const PersonService = require('../service/PersonService')

// 保存个人信息
Router.get("/savePerson", async (req, res, next) => {
  try {
    const { name, password } = req.query
    const personService = new PersonService()
    const person = personService.create({ name, password })
    return res.json({ status:200, msg:'成功', data: person})
  } catch (err) {
    next(err)
  }
})
// 查询用户列表
Router.get("/getPersonList", async (req, res, next) => {
  try {
    const personService = new PersonService()
    const { total, rows} = personService.getList()
    return res.json({ status:200, msg:'成功', data: { total, rows}})
  } catch (err) {
    next(err)
  }
})

module.exports = Router